<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../public/css/monokai_sublime.min.css">
    <link rel="stylesheet" href="../../public/css/heightlength.css">
    <link rel="stylesheet" href="../../public/css/mxjs.css">
    <link rel="stylesheet" href="../../public/css/prism.css">
    <script src="../../public/js/jquery.js"></script>
    <script src="../../public/js/highlight.min.js"></script>
    <script src="../../public/js/prism.js"></script>
    <script src="../../public/js/clipboard.min.js"></script>

</head>
<body>
<button>点击</button>
<div class="container">
    <div class="jsbg">
        <div class="col-lg-12 mxlength">
            <div class="mx-1">
                <h2>字符串前后补全</h2>
                <h2>https://www.cnblogs.com/hongrunhui/p/9370954.html</h2>
                <code>
                    if (!String.prototype.padStart) {
                    String.prototype.padStart = function padStart(targetLength,padString) {
                    targetLength = targetLength>>0; //truncate if number or convert non-number to 0;
                    padString = String((typeof padString !== 'undefined' ? padString : ' '));
                    if (this.length > targetLength) {
                    return String(this);
                    }
                    else {
                    targetLength = targetLength-this.length;
                    if (targetLength > padString.length) {
                    padString += padString.repeat(targetLength/padString.length); //append to original to ensure we are longer than needed
                    }
                    return padString.slice(0,targetLength) + String(this);
                    }
                    };
                    }
                </code>
            </div>
        </div>
        <div class="col-lg-12  ">
      <pre class="mScroll">
        <code class="lang-javascript">

		</code>
    </pre>
        </div>
    </div>
</div>
<script>

    window.onload = function () {
        var clipboard = new Clipboard('.toolbar-item');
        clipboard.on('success', function (e) {
            console.log(e.text);
        });
        clipboard.on('error', function (e) {
            console.log(e);
        });
        $(".toolbar-item").html("<span>复制</span>")
    }
</script>
</body>
</html>
